﻿using System;
using System.Runtime.InteropServices;
using Avalonia;
using Avalonia.Media;

namespace BQDHelper.Desktop;

class Program
{
    // Initialization code. Don't use any Avalonia, third-party APIs or any
    // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
    // yet and stuff might break.
    [STAThread]
    public static void Main(string[] args) => BuildAvaloniaApp()
        .StartWithClassicDesktopLifetime(args);

    // Avalonia configuration, don't remove; also used by visual designer.
    public static AppBuilder BuildAvaloniaApp()
    {
        // 初始化默认的字体名称为空字符串
        string defaultFont = "";

        // 检查当前操作系统是否是 Linux 系统
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            string osDescription = RuntimeInformation.OSDescription.ToLower();
            Console.WriteLine("osDescription: " + osDescription);

            if (osDescription.Contains("uniontech"))
            {
                defaultFont = "Noto Sans";
            }
            else if (osDescription.Contains("kylin"))
            {
                defaultFont = "国标仿宋";
            }
            else if (osDescription.Contains("ubuntu"))
            {
                defaultFont = "Noto Mono";
            }
        }
        var options = new FontManagerOptions
        {
            DefaultFamilyName = defaultFont, // 或使用自定义字体键值，如"MiSans"
            FontFallbacks = new[] { new FontFallback { FontFamily = new FontFamily("avares://BQDHelper/Assets/Fonts/MiSans-Normal.ttf#MiSans") } }
        };
        return AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .With(options)
            .LogToTrace();
    }

}
